#include <cstdio>
#include <algorithm>

using namespace std;

typedef long long ll;
const int maxn=300, mods=998244353;
bool lim[maxn+2][maxn+2][maxn+2];
int nxt[maxn+2];
ll f[maxn+2][maxn+2];

int main() {
    freopen("catalan.in", "r", stdin);
    freopen("catalan.out", "w", stdout);

    int n, m;
    scanf("%d %d", &n, &m);
    for (int i=0; i<=n+1; i++) {
        nxt[i]=n+1;
        if (i) f[i][i-1] = 1;
    }
    for (int i=1; i<=m; i++) {
        int f, g;
        scanf("%d %d", &f, &g);
        if (f<g) nxt[f] = min(nxt[f], g);
        else {
            for (int i=g+1; i<=f; i++) lim[g][f][i]=true;
        }
    }

    for (int i=0; i<n; i++) {
        for (int l=1; l+i<=n; l++) {
            int r=l+i;
            for (int k=l; k<=r; k++) {
                lim[l][r][k] |= lim[l+1][r][k]||lim[l][r-1][k];
                if (nxt[k]>r && !lim[l][r][k]) {
                    f[l][r] = (f[l][r]+f[l][k-1]*f[k+1][r]%mods)%mods;
                }
            }
        }
    }
    printf("%lld\n", f[1][n]);

    fclose(stdin);
    fclose(stdout);
    return 0;
}
